<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">

<title>
  Hantsy
  
  Bai
  
  
  | Testing Jakarta EE 9 Applications with Arquillian and Open Liberty
  
</title>
<meta name="description" content="My personal website focusing on Java EE/Jakarta EE and Spring.
">

<!-- Open Graph -->


<!-- Bootstrap & MDB -->
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
  rel="stylesheet" integrity="sha512-MoRNloxbStBcD8z3M/2BmnT+rg4IsMxPkXaGh2zD6LGNNFE80W3onsAhRcMAMrSoyWL9xD7Ert0men7vR8LUZg==" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/css/mdb.min.css"
  integrity="sha512-RO38pBRxYH3SoOprtPTD86JFOclM51/XTIdEPh5j8sj4tp8jmQIx26twG52UaLi//hQldfrh7e51WzP9wuP32Q==" crossorigin="anonymous" />

<!-- Fonts & Icons -->
<link rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.14.0/css/all.min.css"
  integrity="sha512-1PKOgIY59xJ8Co8+NE6FZ+LOAZKjy+KY8iq0G4B3CyeY6wYHN3yt9PW0XpSriVlkMXe40PTKnXrLnZ9+fkDaog==" crossorigin="anonymous">
<link rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.9.0/css/academicons.min.css"
  integrity="sha512-W4yqoT1+8NLkinBLBZko+dFB2ZbHsYLDdr50VElllRcNt2Q4/GSs6u71UHKxB7S6JEMCp5Ve4xjh3eGQl/HRvg==" crossorigin="anonymous">
<link rel="stylesheet" type="text/css"
  href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Slab:100,300,400,500,700|Material+Icons">

<!-- Code Syntax Highlighting -->
<link rel="stylesheet"
  href="https://gitcdn.link/repo/jwarby/jekyll-pygments-themes/master/github.css" />

<!-- Styles -->
<link rel="shortcut icon" href="/assets/img/favicon.ico">
<link rel="stylesheet" href="/assets/css/main.css">

<link rel="canonical" href="/blog/2020/testing-jakarta-ee-9-applications-with-arquillian-and-open-liberty/">

<!-- JQuery -->
<!-- jQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>


<!-- Theming-->

<script src="/assets/js/theme.js"></script>
<!-- Load DarkMode JS -->
<script src="/assets/js/dark_mode.js"></script>



<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-18SZ2W3GXD"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag() { dataLayer.push(arguments); }
  gtag('js', new Date());

  gtag('config', 'G-18SZ2W3GXD');
</script>




  
<!-- MathJax -->
<script type="text/javascript">
  window.MathJax = {
    tex: {
      tags: 'ams'
    }
  };
</script>
<script defer type="text/javascript" id="MathJax-script" src="https://cdn.jsdelivr.net/npm/mathjax@3.1.2/es5/tex-mml-chtml.js"></script>
<script defer src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>


  <link type="application/atom+xml" rel="alternate" href="/feed.xml" title="blank" />
  <!-- Begin Jekyll SEO tag v2.7.1 -->
<meta name="generator" content="Jekyll v3.9.0" />
<meta property="og:title" content="Testing Jakarta EE 9 Applications with Arquillian and Open Liberty" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="The OpenLiberty/arquillian-liberty has began to add Jakarta EE 9 support. For impatient users, you can taste the current work in your project now. In this post, we will try to run the our tests on the Open Liberty container using both managed and remote adapters. Prerequisites Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)The latest Apache MavenThe basic knowledge of JUnit 5Get to know the basic of Arquillian Before adding Open Liberty and Aquilian integration configuration into your project, please make sure you have added Arquillian Jarkarta EE 9 and JUnit 5 dependencies. Configuring OpenLiberty Managed Container Adapter Add arquillian-liberty-managed-jakarta dependency into your project. &lt;dependency&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-managed-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;&lt;/dependency&gt; Define the arquillian-liberty-jakarta.version property in the properties section. &lt;arquillian-liberty-jakarta.version&gt;2.0.0-M1&lt;/arquillian-liberty-jakarta.version&gt; NOTE: For the Jakarta EE 9, the arquillian-liberty project uses a new namespace, please note the groupId(arquillian-liberty-managed-jakarta ), it has a -jakarta postfix. If you are using Jakarta Restful WS Client in your test codes to shake hands with your Restful Web Services, you should add a Restful WS Client implementation into the test scope. But I found the Open Liberty 21.0.0.1-beta is a little different from the previous Jakarta EE 8 compatible version, the Restful WS implementation is changed to Resteasy. But Resteasy still does not provide a public version for Jakarta EE 9. Till now, only Jersey completed the Jakarta EE 9 transformation. So add the jersey-client related dependencies. &lt;!-- Jersey --&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-sse&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-json-binding&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.inject&lt;/groupId&gt; &lt;artifactId&gt;jersey-hk2&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt; &lt;artifactId&gt;jersey-client&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt; Create a container configuration in the arquillian.xml file. &lt;container qualifier=&quot;liberty-managed&quot;&gt; &lt;configuration&gt; &lt;property name=&quot;wlpHome&quot;&gt;target/wlp/&lt;/property&gt; &lt;property name=&quot;serverName&quot;&gt;defaultServer&lt;/property&gt; &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt; &lt;property name=&quot;serverStartTimeout&quot;&gt;300&lt;/property&gt; &lt;/configuration&gt;&lt;/container&gt; You can configure a wlpHome to use the existing Open Liberty server in your local system. To get a clean environment to run your tests every time, I use a Dependency Maven Plugin to download a copy of Open Liberty, and use it to run your tests. It is good to automate the progress in a CI server. &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;version&gt;${maven-dependency-plugin.version}&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;pre-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;io.openliberty.beta&lt;/groupId&gt; &lt;artifactId&gt;openliberty-runtime&lt;/artifactId&gt; &lt;version&gt;${liberty.runtime.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;artifactItem&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-support-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;classifier&gt;feature&lt;/classifier&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}/wlp/usr&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt;&lt;/plugin&gt;&lt;plugin&gt; &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt; &lt;version&gt;${maven-failsafe-plugin.version}&lt;/version&gt; &lt;configuration&gt; &lt;systemPropertyVariables&gt; &lt;arquillian.launch&gt;liberty-managed&lt;/arquillian.launch&gt; &lt;java.util.logging.config.file&gt;${project.build.testOutputDirectory}/logging.properties &lt;/java.util.logging.config.file&gt; &lt;/systemPropertyVariables&gt; &lt;/configuration&gt;&lt;/plugin&gt; Use a Open Liberty server.xml for test purpose. &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;server description=&quot;new server&quot;&gt; &lt;!-- Enable features --&gt; &lt;featureManager&gt; &lt;feature&gt;jakartaee-9.0&lt;/feature&gt; &lt;feature&gt;usr:arquillian-support-jakarta-2.0&lt;/feature&gt; &lt;feature&gt;localConnector-1.0&lt;/feature&gt; &lt;/featureManager&gt; &lt;!-- To access this server from a remote client add a host attribute to the following element, e.g. host=&quot;*&quot; --&gt; &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot; httpPort=&quot;9080&quot; httpsPort=&quot;9443&quot; /&gt; &lt;!-- Automatically expand WAR files and EAR files --&gt; &lt;applicationManager updateTrigger=&quot;mbean&quot; autoExpand=&quot;true&quot;/&gt; &lt;/server&gt; To make our Open Liberty arquillian adapter work, you have to configure a localConnector feature, arquillian-support-jakarta-2.0 is helpful in development and used to gather more concise exception info from Open Liberty when running the tests. Execute the following command to run the tests. mvn clean verify -Parq-libery-managed Configuring Open Liberty Remote Container Adapter With Open Liberty Remote Container Adapter, you can run the tests against a running Open Liberty server, esp. it is running on a different server. Adding the following arquillian-liberty-remote-jakarta dependency instead. &lt;dependency&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-remote-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;&lt;/dependency&gt;// the jersey client depdenceies are omitted. And add a container section in the arquillian.xml file for this remote container. &lt;container qualifier=&quot;liberty-remote&quot;&gt; &lt;configuration&gt; &lt;property name=&quot;hostName&quot;&gt;localhost&lt;/property&gt; &lt;property name=&quot;serverName&quot;&gt;testServer&lt;/property&gt; &lt;property name=&quot;username&quot;&gt;admin&lt;/property&gt; &lt;property name=&quot;password&quot;&gt;admin&lt;/property&gt; &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt; &lt;property name=&quot;httpsPort&quot;&gt;9443&lt;/property&gt; &lt;/configuration&gt; &lt;/container&gt; By default, when you start Open Liberty at the first time, it will create a new defaultServer configuration. For the test purpose, we create a new testServer. server create testServer Replace the generated server.xml in [Open Liberty dir]/usr/servers/testServer/server.xml with following content. &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;server description=&quot;Jakarta EE 9 test server&quot;&gt; &lt;!-- Enable features --&gt; &lt;featureManager&gt; &lt;feature&gt;jakartaee-9.0&lt;/feature&gt; &lt;feature&gt;restConnector-2.0&lt;/feature&gt; &lt;/featureManager&gt; &lt;quickStartSecurity userName=&quot;admin&quot; userPassword=&quot;admin&quot; /&gt; &lt;!-- Default SSL configuration enables trust for default certificates from the Java runtime --&gt; &lt;ssl id=&quot;defaultSSLConfig&quot; trustDefaultCerts=&quot;true&quot;/&gt; &lt;keyStore id=&quot;defaultKeyStore&quot; password=&quot;password&quot; location=&quot;key.jks&quot; type=&quot;JKS&quot;/&gt; &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot; httpPort=&quot;9080&quot; httpsPort=&quot;9443&quot; host=&quot;*&quot;/&gt; &lt;!-- Automatically expand WAR files and EAR files --&gt; &lt;applicationManager autoExpand=&quot;true&quot; updateTrigger=&quot;mbean&quot; /&gt; &lt;logging consoleLogLevel=&quot;INFO&quot; /&gt; &lt;writeDir&gt;${server.config.dir}/dropins&lt;/writeDir&gt; &lt;/remoteFileAccess&gt; &lt;/server&gt; Start the server, it will prepare the required resources defined in the server.xml file. # start server testServerserver start testServer For remote connections, it depends on restConnector-2.0 feature, and it enabled the SSL connection. To avoid the SSL certificate exception when running our tests, you should export the certificate from the running OpenLiberty server, and import it into the client JVM certs, as we done in the Testing with Arquillian and Glassfish. keytool -export -alias default -file testwlp.crt -keystore [Open Liberty install dir]/usr/servers/testServer/reources/security/key.jks keytool -import -trustcacerts -keystore ${JAVA_HOME}/jre/lib/security/cacerts -storepass changeit -alias testwlp -file testwlp.crt -noprompt Before executing the tests, make sure the target Open Liberty server is running. Execute the following command to run tests . mvn clean verfiy -Parq-liberty-managed Grab a copy of the source codes from my Github, and explore yourself. &lt;hr&gt;&lt;p&gt;Testing Jakarta EE 9 Applications with Arquillian and Open Liberty was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;" />
<meta property="og:description" content="The OpenLiberty/arquillian-liberty has began to add Jakarta EE 9 support. For impatient users, you can taste the current work in your project now. In this post, we will try to run the our tests on the Open Liberty container using both managed and remote adapters. Prerequisites Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)The latest Apache MavenThe basic knowledge of JUnit 5Get to know the basic of Arquillian Before adding Open Liberty and Aquilian integration configuration into your project, please make sure you have added Arquillian Jarkarta EE 9 and JUnit 5 dependencies. Configuring OpenLiberty Managed Container Adapter Add arquillian-liberty-managed-jakarta dependency into your project. &lt;dependency&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-managed-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;&lt;/dependency&gt; Define the arquillian-liberty-jakarta.version property in the properties section. &lt;arquillian-liberty-jakarta.version&gt;2.0.0-M1&lt;/arquillian-liberty-jakarta.version&gt; NOTE: For the Jakarta EE 9, the arquillian-liberty project uses a new namespace, please note the groupId(arquillian-liberty-managed-jakarta ), it has a -jakarta postfix. If you are using Jakarta Restful WS Client in your test codes to shake hands with your Restful Web Services, you should add a Restful WS Client implementation into the test scope. But I found the Open Liberty 21.0.0.1-beta is a little different from the previous Jakarta EE 8 compatible version, the Restful WS implementation is changed to Resteasy. But Resteasy still does not provide a public version for Jakarta EE 9. Till now, only Jersey completed the Jakarta EE 9 transformation. So add the jersey-client related dependencies. &lt;!-- Jersey --&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-sse&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-json-binding&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.inject&lt;/groupId&gt; &lt;artifactId&gt;jersey-hk2&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt; &lt;artifactId&gt;jersey-client&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt; Create a container configuration in the arquillian.xml file. &lt;container qualifier=&quot;liberty-managed&quot;&gt; &lt;configuration&gt; &lt;property name=&quot;wlpHome&quot;&gt;target/wlp/&lt;/property&gt; &lt;property name=&quot;serverName&quot;&gt;defaultServer&lt;/property&gt; &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt; &lt;property name=&quot;serverStartTimeout&quot;&gt;300&lt;/property&gt; &lt;/configuration&gt;&lt;/container&gt; You can configure a wlpHome to use the existing Open Liberty server in your local system. To get a clean environment to run your tests every time, I use a Dependency Maven Plugin to download a copy of Open Liberty, and use it to run your tests. It is good to automate the progress in a CI server. &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;version&gt;${maven-dependency-plugin.version}&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;pre-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;io.openliberty.beta&lt;/groupId&gt; &lt;artifactId&gt;openliberty-runtime&lt;/artifactId&gt; &lt;version&gt;${liberty.runtime.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;artifactItem&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-support-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;classifier&gt;feature&lt;/classifier&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}/wlp/usr&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt;&lt;/plugin&gt;&lt;plugin&gt; &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt; &lt;version&gt;${maven-failsafe-plugin.version}&lt;/version&gt; &lt;configuration&gt; &lt;systemPropertyVariables&gt; &lt;arquillian.launch&gt;liberty-managed&lt;/arquillian.launch&gt; &lt;java.util.logging.config.file&gt;${project.build.testOutputDirectory}/logging.properties &lt;/java.util.logging.config.file&gt; &lt;/systemPropertyVariables&gt; &lt;/configuration&gt;&lt;/plugin&gt; Use a Open Liberty server.xml for test purpose. &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;server description=&quot;new server&quot;&gt; &lt;!-- Enable features --&gt; &lt;featureManager&gt; &lt;feature&gt;jakartaee-9.0&lt;/feature&gt; &lt;feature&gt;usr:arquillian-support-jakarta-2.0&lt;/feature&gt; &lt;feature&gt;localConnector-1.0&lt;/feature&gt; &lt;/featureManager&gt; &lt;!-- To access this server from a remote client add a host attribute to the following element, e.g. host=&quot;*&quot; --&gt; &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot; httpPort=&quot;9080&quot; httpsPort=&quot;9443&quot; /&gt; &lt;!-- Automatically expand WAR files and EAR files --&gt; &lt;applicationManager updateTrigger=&quot;mbean&quot; autoExpand=&quot;true&quot;/&gt; &lt;/server&gt; To make our Open Liberty arquillian adapter work, you have to configure a localConnector feature, arquillian-support-jakarta-2.0 is helpful in development and used to gather more concise exception info from Open Liberty when running the tests. Execute the following command to run the tests. mvn clean verify -Parq-libery-managed Configuring Open Liberty Remote Container Adapter With Open Liberty Remote Container Adapter, you can run the tests against a running Open Liberty server, esp. it is running on a different server. Adding the following arquillian-liberty-remote-jakarta dependency instead. &lt;dependency&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-remote-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;&lt;/dependency&gt;// the jersey client depdenceies are omitted. And add a container section in the arquillian.xml file for this remote container. &lt;container qualifier=&quot;liberty-remote&quot;&gt; &lt;configuration&gt; &lt;property name=&quot;hostName&quot;&gt;localhost&lt;/property&gt; &lt;property name=&quot;serverName&quot;&gt;testServer&lt;/property&gt; &lt;property name=&quot;username&quot;&gt;admin&lt;/property&gt; &lt;property name=&quot;password&quot;&gt;admin&lt;/property&gt; &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt; &lt;property name=&quot;httpsPort&quot;&gt;9443&lt;/property&gt; &lt;/configuration&gt; &lt;/container&gt; By default, when you start Open Liberty at the first time, it will create a new defaultServer configuration. For the test purpose, we create a new testServer. server create testServer Replace the generated server.xml in [Open Liberty dir]/usr/servers/testServer/server.xml with following content. &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;server description=&quot;Jakarta EE 9 test server&quot;&gt; &lt;!-- Enable features --&gt; &lt;featureManager&gt; &lt;feature&gt;jakartaee-9.0&lt;/feature&gt; &lt;feature&gt;restConnector-2.0&lt;/feature&gt; &lt;/featureManager&gt; &lt;quickStartSecurity userName=&quot;admin&quot; userPassword=&quot;admin&quot; /&gt; &lt;!-- Default SSL configuration enables trust for default certificates from the Java runtime --&gt; &lt;ssl id=&quot;defaultSSLConfig&quot; trustDefaultCerts=&quot;true&quot;/&gt; &lt;keyStore id=&quot;defaultKeyStore&quot; password=&quot;password&quot; location=&quot;key.jks&quot; type=&quot;JKS&quot;/&gt; &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot; httpPort=&quot;9080&quot; httpsPort=&quot;9443&quot; host=&quot;*&quot;/&gt; &lt;!-- Automatically expand WAR files and EAR files --&gt; &lt;applicationManager autoExpand=&quot;true&quot; updateTrigger=&quot;mbean&quot; /&gt; &lt;logging consoleLogLevel=&quot;INFO&quot; /&gt; &lt;writeDir&gt;${server.config.dir}/dropins&lt;/writeDir&gt; &lt;/remoteFileAccess&gt; &lt;/server&gt; Start the server, it will prepare the required resources defined in the server.xml file. # start server testServerserver start testServer For remote connections, it depends on restConnector-2.0 feature, and it enabled the SSL connection. To avoid the SSL certificate exception when running our tests, you should export the certificate from the running OpenLiberty server, and import it into the client JVM certs, as we done in the Testing with Arquillian and Glassfish. keytool -export -alias default -file testwlp.crt -keystore [Open Liberty install dir]/usr/servers/testServer/reources/security/key.jks keytool -import -trustcacerts -keystore ${JAVA_HOME}/jre/lib/security/cacerts -storepass changeit -alias testwlp -file testwlp.crt -noprompt Before executing the tests, make sure the target Open Liberty server is running. Execute the following command to run tests . mvn clean verfiy -Parq-liberty-managed Grab a copy of the source codes from my Github, and explore yourself. &lt;hr&gt;&lt;p&gt;Testing Jakarta EE 9 Applications with Arquillian and Open Liberty was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;" />
<meta property="og:site_name" content="blank" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2020-12-04T00:00:00+00:00" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Testing Jakarta EE 9 Applications with Arquillian and Open Liberty" />
<script type="application/ld+json">
{"datePublished":"2020-12-04T00:00:00+00:00","description":"The OpenLiberty/arquillian-liberty has began to add Jakarta EE 9 support. For impatient users, you can taste the current work in your project now. In this post, we will try to run the our tests on the Open Liberty container using both managed and remote adapters. Prerequisites Java 8 or Java 11 (OpenJDK or AdoptOpenJDK)The latest Apache MavenThe basic knowledge of JUnit 5Get to know the basic of Arquillian Before adding Open Liberty and Aquilian integration configuration into your project, please make sure you have added Arquillian Jarkarta EE 9 and JUnit 5 dependencies. Configuring OpenLiberty Managed Container Adapter Add arquillian-liberty-managed-jakarta dependency into your project. &lt;dependency&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-managed-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;&lt;/dependency&gt; Define the arquillian-liberty-jakarta.version property in the properties section. &lt;arquillian-liberty-jakarta.version&gt;2.0.0-M1&lt;/arquillian-liberty-jakarta.version&gt; NOTE: For the Jakarta EE 9, the arquillian-liberty project uses a new namespace, please note the groupId(arquillian-liberty-managed-jakarta ), it has a -jakarta postfix. If you are using Jakarta Restful WS Client in your test codes to shake hands with your Restful Web Services, you should add a Restful WS Client implementation into the test scope. But I found the Open Liberty 21.0.0.1-beta is a little different from the previous Jakarta EE 8 compatible version, the Restful WS implementation is changed to Resteasy. But Resteasy still does not provide a public version for Jakarta EE 9. Till now, only Jersey completed the Jakarta EE 9 transformation. So add the jersey-client related dependencies. &lt;!-- Jersey --&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-sse&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt; &lt;artifactId&gt;jersey-media-json-binding&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.inject&lt;/groupId&gt; &lt;artifactId&gt;jersey-hk2&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt;&lt;dependency&gt; &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt; &lt;artifactId&gt;jersey-client&lt;/artifactId&gt; &lt;version&gt;${jersey.version}&lt;/version&gt; &lt;scope&gt;test&lt;/scope&gt;&lt;/dependency&gt; Create a container configuration in the arquillian.xml file. &lt;container qualifier=&quot;liberty-managed&quot;&gt; &lt;configuration&gt; &lt;property name=&quot;wlpHome&quot;&gt;target/wlp/&lt;/property&gt; &lt;property name=&quot;serverName&quot;&gt;defaultServer&lt;/property&gt; &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt; &lt;property name=&quot;serverStartTimeout&quot;&gt;300&lt;/property&gt; &lt;/configuration&gt;&lt;/container&gt; You can configure a wlpHome to use the existing Open Liberty server in your local system. To get a clean environment to run your tests every time, I use a Dependency Maven Plugin to download a copy of Open Liberty, and use it to run your tests. It is good to automate the progress in a CI server. &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt; &lt;version&gt;${maven-dependency-plugin.version}&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;unpack&lt;/id&gt; &lt;phase&gt;pre-integration-test&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;unpack&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;artifactItems&gt; &lt;artifactItem&gt; &lt;groupId&gt;io.openliberty.beta&lt;/groupId&gt; &lt;artifactId&gt;openliberty-runtime&lt;/artifactId&gt; &lt;version&gt;${liberty.runtime.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;artifactItem&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-support-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt; &lt;type&gt;zip&lt;/type&gt; &lt;classifier&gt;feature&lt;/classifier&gt; &lt;overWrite&gt;false&lt;/overWrite&gt; &lt;outputDirectory&gt;${project.build.directory}/wlp/usr&lt;/outputDirectory&gt; &lt;/artifactItem&gt; &lt;/artifactItems&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt;&lt;/plugin&gt;&lt;plugin&gt; &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt; &lt;version&gt;${maven-failsafe-plugin.version}&lt;/version&gt; &lt;configuration&gt; &lt;systemPropertyVariables&gt; &lt;arquillian.launch&gt;liberty-managed&lt;/arquillian.launch&gt; &lt;java.util.logging.config.file&gt;${project.build.testOutputDirectory}/logging.properties &lt;/java.util.logging.config.file&gt; &lt;/systemPropertyVariables&gt; &lt;/configuration&gt;&lt;/plugin&gt; Use a Open Liberty server.xml for test purpose. &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;server description=&quot;new server&quot;&gt; &lt;!-- Enable features --&gt; &lt;featureManager&gt; &lt;feature&gt;jakartaee-9.0&lt;/feature&gt; &lt;feature&gt;usr:arquillian-support-jakarta-2.0&lt;/feature&gt; &lt;feature&gt;localConnector-1.0&lt;/feature&gt; &lt;/featureManager&gt; &lt;!-- To access this server from a remote client add a host attribute to the following element, e.g. host=&quot;*&quot; --&gt; &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot; httpPort=&quot;9080&quot; httpsPort=&quot;9443&quot; /&gt; &lt;!-- Automatically expand WAR files and EAR files --&gt; &lt;applicationManager updateTrigger=&quot;mbean&quot; autoExpand=&quot;true&quot;/&gt; &lt;/server&gt; To make our Open Liberty arquillian adapter work, you have to configure a localConnector feature, arquillian-support-jakarta-2.0 is helpful in development and used to gather more concise exception info from Open Liberty when running the tests. Execute the following command to run the tests. mvn clean verify -Parq-libery-managed Configuring Open Liberty Remote Container Adapter With Open Liberty Remote Container Adapter, you can run the tests against a running Open Liberty server, esp. it is running on a different server. Adding the following arquillian-liberty-remote-jakarta dependency instead. &lt;dependency&gt; &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt; &lt;artifactId&gt;arquillian-liberty-remote-jakarta&lt;/artifactId&gt; &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;&lt;/dependency&gt;// the jersey client depdenceies are omitted. And add a container section in the arquillian.xml file for this remote container. &lt;container qualifier=&quot;liberty-remote&quot;&gt; &lt;configuration&gt; &lt;property name=&quot;hostName&quot;&gt;localhost&lt;/property&gt; &lt;property name=&quot;serverName&quot;&gt;testServer&lt;/property&gt; &lt;property name=&quot;username&quot;&gt;admin&lt;/property&gt; &lt;property name=&quot;password&quot;&gt;admin&lt;/property&gt; &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt; &lt;property name=&quot;httpsPort&quot;&gt;9443&lt;/property&gt; &lt;/configuration&gt; &lt;/container&gt; By default, when you start Open Liberty at the first time, it will create a new defaultServer configuration. For the test purpose, we create a new testServer. server create testServer Replace the generated server.xml in [Open Liberty dir]/usr/servers/testServer/server.xml with following content. &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;server description=&quot;Jakarta EE 9 test server&quot;&gt; &lt;!-- Enable features --&gt; &lt;featureManager&gt; &lt;feature&gt;jakartaee-9.0&lt;/feature&gt; &lt;feature&gt;restConnector-2.0&lt;/feature&gt; &lt;/featureManager&gt; &lt;quickStartSecurity userName=&quot;admin&quot; userPassword=&quot;admin&quot; /&gt; &lt;!-- Default SSL configuration enables trust for default certificates from the Java runtime --&gt; &lt;ssl id=&quot;defaultSSLConfig&quot; trustDefaultCerts=&quot;true&quot;/&gt; &lt;keyStore id=&quot;defaultKeyStore&quot; password=&quot;password&quot; location=&quot;key.jks&quot; type=&quot;JKS&quot;/&gt; &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot; httpPort=&quot;9080&quot; httpsPort=&quot;9443&quot; host=&quot;*&quot;/&gt; &lt;!-- Automatically expand WAR files and EAR files --&gt; &lt;applicationManager autoExpand=&quot;true&quot; updateTrigger=&quot;mbean&quot; /&gt; &lt;logging consoleLogLevel=&quot;INFO&quot; /&gt; &lt;writeDir&gt;${server.config.dir}/dropins&lt;/writeDir&gt; &lt;/remoteFileAccess&gt; &lt;/server&gt; Start the server, it will prepare the required resources defined in the server.xml file. # start server testServerserver start testServer For remote connections, it depends on restConnector-2.0 feature, and it enabled the SSL connection. To avoid the SSL certificate exception when running our tests, you should export the certificate from the running OpenLiberty server, and import it into the client JVM certs, as we done in the Testing with Arquillian and Glassfish. keytool -export -alias default -file testwlp.crt -keystore [Open Liberty install dir]/usr/servers/testServer/reources/security/key.jks keytool -import -trustcacerts -keystore ${JAVA_HOME}/jre/lib/security/cacerts -storepass changeit -alias testwlp -file testwlp.crt -noprompt Before executing the tests, make sure the target Open Liberty server is running. Execute the following command to run tests . mvn clean verfiy -Parq-liberty-managed Grab a copy of the source codes from my Github, and explore yourself. &lt;hr&gt;&lt;p&gt;Testing Jakarta EE 9 Applications with Arquillian and Open Liberty was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.&lt;/p&gt;","mainEntityOfPage":{"@type":"WebPage","@id":"/blog/2020/testing-jakarta-ee-9-applications-with-arquillian-and-open-liberty/"},"url":"/blog/2020/testing-jakarta-ee-9-applications-with-arquillian-and-open-liberty/","@type":"BlogPosting","headline":"Testing Jakarta EE 9 Applications with Arquillian and Open Liberty","dateModified":"2020-12-04T00:00:00+00:00","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->

</head>

<body
  class="fixed-top-nav ">

  <!-- Header -->

  <header>

    <!-- Nav Bar -->
    <nav id="navbar" class="navbar navbar-light navbar-expand-sm fixed-top">
    <div class="container">
      
      <a class="navbar-brand title font-weight-lighter" href="/">
       <span class="font-weight-bold">Hantsy</span>   Bai
      </a>
      
      <!-- Navbar Toggle -->
      <button class="navbar-toggler collapsed ml-auto" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar top-bar"></span>
        <span class="icon-bar middle-bar"></span>
        <span class="icon-bar bottom-bar"></span>
      </button>
      <div class="collapse navbar-collapse text-right" id="navbarNav">
        <ul class="navbar-nav ml-auto flex-nowrap">
          <!-- About -->
          <li class="nav-item ">
            <a class="nav-link" href="/">
              about
              
            </a>
          </li>
          
          <!-- Blog -->
          <li class="nav-item active">
            <a class="nav-link" href="/blog/">
              blog
              
            </a>
          </li>
          
          <!-- Other pages -->
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/projects/">
                projects
                
              </a>
          </li>
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/publications/">
                publications
                
              </a>
          </li>
          
          
          
          <li class="nav-item ">
              <a class="nav-link" href="/service/">
                service
                
              </a>
          </li>
          
          
          
            <div class = "toggle-container">
              <a id = "light-toggle">
                  <i class="fas fa-moon"></i>
                  <i class="fas fa-sun"></i>
              </a>
            </div>
          
        </ul>
      </div>
    </div>
  </nav>

</header>


  <!-- Content -->

  <div class="container mt-5">
    

<div class="post">

  <header class="post-header">
    <h1 class="post-title">Testing Jakarta EE 9 Applications with Arquillian and Open Liberty</h1>
    <p class="post-meta">December 4, 2020</p>
  </header>

  <article class="post-content">
    <p>The <a href="https://github.com/OpenLiberty/liberty-arquillian">OpenLiberty/arquillian-liberty</a> has began to <a href="https://github.com/OpenLiberty/liberty-arquillian/issues/71">add Jakarta EE 9 support</a>. For impatient users, you can taste the current work in your project now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZgar-TMaqJ9r-ovXsLz_A.png" /></figure><p>In this post, we will try to run the our tests on the Open Liberty container using both managed and remote adapters.</p><h3>Prerequisites</h3><ul><li>Java 8 or Java 11 (<a href="https://openjdk.java.net/install/">OpenJDK</a> or <a href="https://adoptopenjdk.net/installation.html">AdoptOpenJDK</a>)</li><li>The latest <a href="http://maven.apache.org/download.cgi">Apache Maven</a></li><li>The basic knowledge of <a href="https://junit.org/junit5/">JUnit 5</a></li><li>Get to know <a href="http://arquillian.org/guides/">the basic of Arquillian</a></li></ul><p>Before adding Open Liberty and Aquilian integration configuration into your project, please make sure you have added <a href="https://github.com/hantsy/jakartaee9-starter-boilerplate/blob/master/docs/docs/arq-weld.md">Arquillian Jarkarta EE 9 and JUnit 5 dependencies</a>.</p><h3>Configuring OpenLiberty Managed Container Adapter</h3><p>Add arquillian-liberty-managed-jakarta dependency into your project.</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt;<br>    &lt;artifactId&gt;arquillian-liberty-managed-jakarta&lt;/artifactId&gt;<br>    &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;<br>&lt;/dependency&gt;</pre><p>Define the arquillian-liberty-jakarta.version property in the <em>properties</em> section.</p><pre>&lt;arquillian-liberty-jakarta.version&gt;2.0.0-M1&lt;/arquillian-liberty-jakarta.version&gt;</pre><blockquote><em>NOTE: For the Jakarta EE 9, the </em><a href="https://github.com/OpenLiberty/liberty-arquillian"><em>arquillian-liberty</em></a><em> project uses a new namespace, please note the groupId(</em><em>arquillian-liberty-managed-jakarta ), it has a </em><strong><em>-jakarta</em></strong><em> postfix.</em></blockquote><p>If you are using Jakarta Restful WS Client in your test codes to shake hands with your Restful Web Services, you should add a Restful WS Client implementation into the <strong>test</strong> scope. But I found the Open Liberty 21.0.0.1-beta is a little different from the previous Jakarta EE 8 compatible version, the Restful WS implementation is changed to Resteasy. But Resteasy still does not provide a public version for Jakarta EE 9. Till now, only Jersey completed the Jakarta EE 9 transformation.</p><p>So add the <strong>jersey-client</strong> related dependencies.</p><pre>&lt;!-- Jersey --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;<br>    &lt;artifactId&gt;jersey-media-sse&lt;/artifactId&gt;<br>    &lt;version&gt;${jersey.version}&lt;/version&gt;<br>    &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;<br>    &lt;artifactId&gt;jersey-media-json-binding&lt;/artifactId&gt;<br>    &lt;version&gt;${jersey.version}&lt;/version&gt;<br>    &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.glassfish.jersey.inject&lt;/groupId&gt;<br>    &lt;artifactId&gt;jersey-hk2&lt;/artifactId&gt;<br>    &lt;version&gt;${jersey.version}&lt;/version&gt;<br>    &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;<br>    &lt;artifactId&gt;jersey-client&lt;/artifactId&gt;<br>    &lt;version&gt;${jersey.version}&lt;/version&gt;<br>    &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><p>Create a container configuration in the <em>arquillian.xml</em> file.</p><pre>&lt;container qualifier=&quot;liberty-managed&quot;&gt;<br>    &lt;configuration&gt;<br>        &lt;property name=&quot;wlpHome&quot;&gt;target/wlp/&lt;/property&gt;<br>        &lt;property name=&quot;serverName&quot;&gt;defaultServer&lt;/property&gt;<br>        &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt;<br>        &lt;property name=&quot;serverStartTimeout&quot;&gt;300&lt;/property&gt;<br>    &lt;/configuration&gt;<br>&lt;/container&gt;</pre><p>You can configure a <em>wlpHome</em> to use the existing <em>Open Liberty</em> server in your local system.</p><p>To get a clean environment to run your tests every time, I use a <strong>Dependency Maven Plugin</strong> to download a copy of Open Liberty, and use it to run your tests. It is good to automate the progress in a CI server.</p><pre>&lt;plugin&gt;<br>    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;<br>    &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;<br>    &lt;version&gt;${maven-dependency-plugin.version}&lt;/version&gt;<br>    &lt;executions&gt;<br>        &lt;execution&gt;<br>            &lt;id&gt;unpack&lt;/id&gt;<br>            &lt;phase&gt;pre-integration-test&lt;/phase&gt;<br>            &lt;goals&gt;<br>                &lt;goal&gt;unpack&lt;/goal&gt;<br>            &lt;/goals&gt;<br>            &lt;configuration&gt;<br>                &lt;artifactItems&gt;<br>                    &lt;artifactItem&gt;<br>                        &lt;groupId&gt;io.openliberty.beta&lt;/groupId&gt;<br>                        &lt;artifactId&gt;openliberty-runtime&lt;/artifactId&gt;<br>                        &lt;version&gt;${liberty.runtime.version}&lt;/version&gt;<br>                        &lt;type&gt;zip&lt;/type&gt;<br>                        &lt;overWrite&gt;false&lt;/overWrite&gt;<br>                        &lt;outputDirectory&gt;${project.build.directory}&lt;/outputDirectory&gt;<br>                    &lt;/artifactItem&gt;<br>                    &lt;artifactItem&gt;<br>                        &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt;<br>                        &lt;artifactId&gt;arquillian-liberty-support-jakarta&lt;/artifactId&gt;<br>                        &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;<br>                        &lt;type&gt;zip&lt;/type&gt;<br>                        &lt;classifier&gt;feature&lt;/classifier&gt;<br>                        &lt;overWrite&gt;false&lt;/overWrite&gt;<br>                        &lt;outputDirectory&gt;${project.build.directory}/wlp/usr&lt;/outputDirectory&gt;<br>                    &lt;/artifactItem&gt;<br>                &lt;/artifactItems&gt;<br>            &lt;/configuration&gt;<br>        &lt;/execution&gt;<br>    &lt;/executions&gt;<br>&lt;/plugin&gt;<br>&lt;plugin&gt;<br>    &lt;artifactId&gt;maven-failsafe-plugin&lt;/artifactId&gt;<br>    &lt;version&gt;${maven-failsafe-plugin.version}&lt;/version&gt;<br>    &lt;configuration&gt;<br>        &lt;systemPropertyVariables&gt;<br>            &lt;arquillian.launch&gt;liberty-managed&lt;/arquillian.launch&gt;<br>            &lt;java.util.logging.config.file&gt;${project.build.testOutputDirectory}/logging.properties<br>            &lt;/java.util.logging.config.file&gt;<br>        &lt;/systemPropertyVariables&gt;<br>    &lt;/configuration&gt;<br>&lt;/plugin&gt;</pre><p>Use a Open Liberty <em>server.xml</em> for test purpose.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;server description=&quot;new server&quot;&gt;</pre><pre>    &lt;!-- Enable features --&gt;<br>    &lt;featureManager&gt;<br>        &lt;feature&gt;jakartaee-9.0&lt;/feature&gt;<br>        &lt;feature&gt;usr:arquillian-support-jakarta-2.0&lt;/feature&gt;<br>        &lt;feature&gt;localConnector-1.0&lt;/feature&gt;<br>    &lt;/featureManager&gt;<br>    <br>    &lt;!-- To access this server from a remote client add a host attribute to the following element, e.g. host=&quot;*&quot; --&gt;<br>    &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot;<br>                  httpPort=&quot;9080&quot;<br>                  httpsPort=&quot;9443&quot; /&gt;<br>                  <br>    &lt;!-- Automatically expand WAR files and EAR files --&gt;<br>    &lt;applicationManager updateTrigger=&quot;mbean&quot;  autoExpand=&quot;true&quot;/&gt;</pre><pre>&lt;/server&gt;</pre><p>To make our Open Liberty arquillian adapter work, you have to configure a localConnector feature, arquillian-support-jakarta-2.0 is helpful in development and used to gather more concise exception info from Open Liberty when running the tests.</p><p>Execute the following command to run the tests.</p><pre>mvn clean verify -Parq-libery-managed</pre><h3>Configuring Open Liberty Remote Container Adapter</h3><p>With Open Liberty Remote Container Adapter, you can run the tests against a running Open Liberty server, esp. it is running on a different server.</p><p>Adding the following arquillian-liberty-remote-jakarta dependency instead.</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;io.openliberty.arquillian&lt;/groupId&gt;<br>    &lt;artifactId&gt;arquillian-liberty-remote-jakarta&lt;/artifactId&gt;<br>    &lt;version&gt;${arquillian-liberty-jakarta.version}&lt;/version&gt;<br>&lt;/dependency&gt;<br>// the jersey client depdenceies are omitted.</pre><p>And add a <em>container</em> section in the <em>arquillian.xml</em> file for this remote container.</p><pre>&lt;container qualifier=&quot;liberty-remote&quot;&gt;<br>        &lt;configuration&gt;<br>            &lt;property name=&quot;hostName&quot;&gt;localhost&lt;/property&gt;<br>            &lt;property name=&quot;serverName&quot;&gt;testServer&lt;/property&gt;<br>            &lt;property name=&quot;username&quot;&gt;admin&lt;/property&gt;<br>            &lt;property name=&quot;password&quot;&gt;admin&lt;/property&gt;<br>            &lt;property name=&quot;httpPort&quot;&gt;9080&lt;/property&gt;<br>            &lt;property name=&quot;httpsPort&quot;&gt;9443&lt;/property&gt;<br>        &lt;/configuration&gt;<br>    &lt;/container&gt;</pre><p>By default, when you start Open Liberty at the first time, it will create a new <em>defaultServer</em> configuration.</p><p>For the test purpose, we create a new <em>testServer</em>.</p><pre>server create testServer</pre><p>Replace the generated server.xml in <em>[Open Liberty dir]/usr/servers/testServer/server.xml</em> with following content.</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;server description=&quot;Jakarta EE 9 test server&quot;&gt;</pre><pre>    &lt;!-- Enable features --&gt;<br>    &lt;featureManager&gt;<br>        &lt;feature&gt;jakartaee-9.0&lt;/feature&gt;<br>        &lt;feature&gt;restConnector-2.0&lt;/feature&gt;<br>    &lt;/featureManager&gt;</pre><pre>    &lt;quickStartSecurity userName=&quot;admin&quot; userPassword=&quot;admin&quot; /&gt;</pre><pre>    &lt;!-- Default SSL configuration enables trust for default certificates from the Java runtime --&gt;<br>    &lt;ssl id=&quot;defaultSSLConfig&quot; trustDefaultCerts=&quot;true&quot;/&gt;</pre><pre>    &lt;keyStore id=&quot;defaultKeyStore&quot; password=&quot;password&quot; location=&quot;key.jks&quot; type=&quot;JKS&quot;/&gt;</pre><pre>    &lt;httpEndpoint id=&quot;defaultHttpEndpoint&quot;<br>                  httpPort=&quot;9080&quot;<br>                  httpsPort=&quot;9443&quot; host=&quot;*&quot;/&gt;</pre><pre>    &lt;!-- Automatically expand WAR files and EAR files --&gt;<br>    &lt;applicationManager autoExpand=&quot;true&quot; updateTrigger=&quot;mbean&quot; /&gt;<br>    <br>    &lt;logging consoleLogLevel=&quot;INFO&quot; /&gt;<br>        &lt;writeDir&gt;${server.config.dir}/dropins&lt;/writeDir&gt;<br>    &lt;/remoteFileAccess&gt;<br>    <br>&lt;/server&gt;</pre><p>Start the server, it will prepare the required resources defined in the <em>server.xml</em> file.</p><pre># start server testServer<br>server start testServer</pre><p>For remote connections, it depends on restConnector-2.0 feature, and it enabled the SSL connection.</p><p>To avoid the SSL certificate exception when running our tests, you should export the certificate from the running OpenLiberty server, and import it into the client JVM certs, as we done in the <a href="https://github.com/hantsy/jakartaee9-starter-boilerplate/blob/master/docs/docs/arq-glassfish.md">Testing with Arquillian and Glassfish</a>.</p><pre>keytool -export -alias default -file testwlp.crt -keystore [Open Liberty install dir]/usr/servers/testServer/reources/security/key.jks</pre><pre>keytool -import -trustcacerts -keystore ${JAVA_HOME}/jre/lib/security/cacerts -storepass changeit -alias testwlp -file testwlp.crt -noprompt</pre><blockquote><em>Before executing the tests, make sure the target Open Liberty server is running.</em></blockquote><p>Execute the following command to run tests .</p><pre>mvn clean verfiy -Parq-liberty-managed</pre><p>Grab a copy of <a href="https://github.com/hantsy/jakartaee9-starter-boilerplate">the source codes from my Github</a>, and explore yourself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ada186a0485" width="1" height="1" alt=""><hr><p><a href="https://itnext.io/testing-jakarta-ee-9-applications-with-arquillian-and-open-liberty-5ada186a0485">Testing Jakarta EE 9 Applications with Arquillian and Open Liberty</a> was originally published in <a href="https://itnext.io">ITNEXT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>

  </article>

  

</div>

  </div>

  <!-- Footer -->

  
<footer class="fixed-bottom">
  <div class="container mt-0">
    &copy; Copyright 2021 Hantsy  Bai.
    <span class="mr-auto"></span>
    Powered by <a href="http://jekyllrb.com/" target="_blank">Jekyll</a> with <a href="https://github.com/alshedivat/al-folio">al-folio</a> theme.

    
    

  </div>
</footer>



</body>

<!-- Bootsrap & MDB scripts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.4.4/umd/popper.min.js" integrity="sha512-eUQ9hGdLjBjY3F41CScH3UX+4JDSI9zXeroz7hJ+RteoCaY+GP/LDoM8AO+Pt+DRFw3nXqsjh9Zsts8hnYv8/A==" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha512-M5KW3ztuIICmVIhjSqXe01oV2bpe248gOxqmlcYrEzAvws7Pw3z6BK0iGbrwvdrUQUhi3eXgtxp5I8PDo9YfjQ==" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mdbootstrap/4.19.1/js/mdb.min.js" integrity="sha512-Mug9KHKmroQFMLm93zGrjhibM2z2Obg9l6qFG2qKjXEXkMp/VDkI4uju9m4QKPjWSwQ6O2qzZEnJDEeCw0Blcw==" crossorigin="anonymous"></script>


<!-- Mansory & imagesLoaded -->
<script defer src="https://unpkg.com/masonry-layout@4/dist/masonry.pkgd.min.js"></script>
<script defer src="https://unpkg.com/imagesloaded@4/imagesloaded.pkgd.min.js"></script>
<script defer src="/assets/js/mansory.js" type="text/javascript"></script>





<!-- Load Common JS -->
<script src="/assets/js/common.js"></script>


</html>
